package com.wzy.controller;


import com.wzy.pojo.UndocumentedWorkers;
import com.wzy.service.UndocumentedWorkersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("undocumentedWorkers")
public class UndocumentedWorkersController {
    @Autowired
    private UndocumentedWorkersService undocumentedWorkersService;
    @RequestMapping
    public String undocumentedWorkers(Model model){
        List<UndocumentedWorkers> undocumentedWorkersList= undocumentedWorkersService.findUndocumentedWorkersAll();
        model.addAttribute("undocumentedWorkersList",undocumentedWorkersList);
        return "UndocumentedWorkers";
    }
    @RequestMapping("/updateU")
    public String updateU(UndocumentedWorkers undocumentedWorkers){
        undocumentedWorkersService.updateUndocumentedWorkers(undocumentedWorkers);
        System.out.println("success");
        return "redirect:/undocumentedWorkers";
    }
    @RequestMapping("/deleteU")
    public String deleteS(String ID){
        undocumentedWorkersService.deleteUndocumentedWorkers(ID);
        return "redirect:/undocumentedWorkers";
    }
    @RequestMapping("/addUPage")
    public String addSPage(){
        return "addUndocumentedWorkers";
    }
    @RequestMapping("/addU")
    public String addStudent(UndocumentedWorkers undocumentedWorkers,Model model){
        if (undocumentedWorkersService.addUndocumentedWorkers(undocumentedWorkers)) {
            return "redirect:/residentialPass#undocumentedWorkers";
        } else {
            model.addAttribute("addUndocumentedWorkers", "该人以存在");
            return "addUndocumentedWorkers";
        }

    }

}
